package Arrays101.Day04;

public class Day04_1 {
    public static void main(String[] args) {

        boolean flag = checkIfExist(new int[]{-2,0,10,-19,4,6,-8});
        System.out.println(flag);
    }

    /**
     * Check If N and Its Double Exist
     *
     * Given an array arr of integers, check if there exists two integers N
     * and M such that N is the double of M ( i.e. N = 2 * M).
     * More formally check if there exists two indices i and j such that :
     * i != j
     * 0 <= i, j < arr.length
     * arr[i] == 2 * arr[j]
     * @param arr
     * @return
     */
    public static boolean checkIfExist(int[] arr) {
        for (int i = 0; i < arr.length; i++) {
            for (int j = 0; j < arr.length; j++) {
                if (arr[i]==2*arr[j]&&i!=j){
                    return true;
                }
            }
        }
        return false;
    }
}
